package com.example.hu.Adapter;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.csht.facelib.db.User;
import com.example.hu.R;

import androidx.annotation.NonNull;


public class MyRlUserAdapter extends BaseQuickAdapter<User, BaseViewHolder> {



    public MyRlUserAdapter() {
        super(R.layout.item_rl_user);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, User item) {
        try {
            String name = item.getName();
            Bitmap pic = BitmapFactory.decodeFile(item.getIdPhoto());
            helper.setText(R.id.tv_name,name)
                    .addOnClickListener(R.id.btn_del);
            if (pic == null){
                helper.setImageResource(R.id.iv_pic,R.mipmap.ic_launcher);
            } else {
                helper.setImageBitmap(R.id.iv_pic,pic);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }


}
